package com.xsh.gls.service.impl;

import com.xsh.gls.mapper.Type_FunctionalMapper;
import com.xsh.gls.pojo.Type_Functional;
import com.xsh.gls.service.Type_FunctionalService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class Type_FunctionalServiceImpl implements Type_FunctionalService {
    @Autowired
    private Type_FunctionalMapper type_functionalMapper;
    @Override
    public List<Type_Functional> queryFunctionByTypeId(Integer typeId) throws Exception {
        return type_functionalMapper.selectFunctionByTypeId(typeId);
    }

    @Override
    public boolean updateRole(Integer typeId, int[] checkID) throws Exception {
        boolean flag=false;
        if(type_functionalMapper.delByTypeId(typeId)>0){
            for (int i=0;i<checkID.length;i++){
                if(type_functionalMapper.insertRole(typeId,checkID[i])==1){
                    flag=true;
                }else{
                    flag=false;
                }
            }
        }else{
            flag=false;
        }
        return flag;
    }
}
